package com.wc.AlgoOJ_homework.AlgoOJ_test3.B_智慧十言;

import java.util.Scanner;

/**
 * @Author congge
 * @Date 2024/3/11 19:03
 * @description http://43.138.190.70:8888/p/982?tid=65e5dab127489dab814f76e2
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        while (t-- > 0) {
            int n = sc.nextInt();
            int maxV = 0;
            int a, b;
            int idx = 0;
            for (int i = 1; i <= n; i++) {
                a = sc.nextInt();
                b = sc.nextInt();
                if (a <= 10) {
                    if (b > maxV) {
                        idx = i;
                        maxV = b;
                    }
                }
            }
            System.out.println(idx);
        }
    }
}
